Match Expression
What does it do?
Evaluates a boolean expression (using Filtrex syntax) and routes based on the result. If the expression is true, goes to on_complete. If false or empty, goes to on_failure. Variables used in the expression are provided as additional params.
1. Syntax
<node_name>:
type: func
func_type: system
func_id: matchExpression
params:
expression: "<filtrex expression>"
<variable_name>: "<value or data injection>"
on_complete: <node_if_true>
on_failure: <node_if_false>
required params
typetype of the nodefunc_typehere it will be a system functionfunc_idwhat function are we calling (matchExpression)params.expressiona Filtrex expression that evaluates to true or falseon_completenode to go to when expression is trueon_failurenode to go to when expression is false or whenexpressionis empty/missing
optional params
- Any additional key-value pairs in
params— each key becomes a variable available inside the expression. Values support data injection. departmentassigns the chat to a departmentagentassigns the chat to a specific agent (email address or CRM ID as defined in the Texter agents manager)
2. Examples
Check if a label exists on the chat
start:
type: func
func_type: system
func_id: matchExpression
params:
expression: 'exists(labels) and label in labels'
label: [ "elinor" ]
labels: "%chat:labels%"
on_complete: elinor_handoff_msg
on_failure: start_parseCrmData
Check if message was sent within last 5 days
check_if_sent_within_5_days:
type: func
func_type: system
func_id: matchExpression
params:
expression: 'lastOutMsgTime > fiveDaysAgo'
lastOutMsgTime: '%state:store.lastOutMsg.0.timestamp|toString|parseInt%'
fiveDaysAgo: '%time:now-5d("x")|parseInt%'
on_complete: mini_bot_bulk_marketing
on_failure: check_keywords
Check if orders list is empty
check_if_no_orders:
type: func
func_type: system
func_id: matchExpression
params:
expression: 'empty(orders) or orders in ("404","null", " ")'
orders: '%state:store.ordersCheck%'
on_complete: no_open_orders_menu
on_failure: store_open_orders
Check if incoming message is from a Facebook/Instagram ad
check_if_from_ad:
type: func
func_type: system
func_id: matchExpression
params:
expression: 'not empty(special.0.facebook.referral)'
special: '%messages:latest(1,-1,"in")|column("special")%'
on_complete: store_social_source
on_failure: start_image
Compare two values (CRM branch vs user selection)
check_if_branches_match:
type: func
func_type: system
func_id: matchExpression
params:
expression: "accountBranch == chosenBranch"
accountBranch: '%state:store.account.accBranchId%'
chosenBranch: '%state:store.branchId%'
on_complete: check_working_hours
on_failure: refer_customer_to_branch_number
Check if chat was resolved within last week
check_if_last_msg_within_week:
type: func
func_type: system
func_id: matchExpression
params:
expression: 'exists(lastResolvedRaw) and lastResolved > lastWeek'
lastResolvedRaw: '%chat:resolvedUpdateTime%'
lastResolved: '%chat:resolvedUpdateTime|toString|parseInt%'
lastWeek: '%time:now-7d("X")|parseInt%'
on_complete: handoff
on_failure: new_customer_menu
Check a numeric threshold
check_order_count:
type: func
func_type: system
func_id: matchExpression
params:
expression: 'count > 0'
count: '%state:node.get_orders.response.count%'
on_complete: show_orders
on_failure: no_orders_message
Validate that user input is a number
check_number:
type: func
func_type: system
func_id: matchExpression
params:
expression: 'isNumber(number) and number > 0'
number: "%state:node.input_number%"
on_complete: process_number
on_failure: invalid_input
Validate input length
check_id_length:
type: func
func_type: system
func_id: matchExpression
params:
expression: 'length == 9'
length: "%state:node.input_id.text|length%"
on_complete: valid_id
on_failure: invalid_id
Validate Israeli phone format
check_phone_format:
type: func
func_type: system
func_id: matchExpression
params:
expression: 'not empty(parsedPhone)'
parsedPhone: "%state:node.input_phone.text|formatPhone(\"e164\",\"IL\")%"
on_complete: valid_phone
on_failure: invalid_phone
Available Filtrex functions
| Function | Description |
|---|---|
exists(x) | Returns true if x is defined and not null |
empty(x) | Returns true if x is empty, null, or undefined |
strlen(x) | Returns the string length of x |
includes(arr, val) | Returns true if array arr contains val |
wordCount(x) | Returns the word count of x |
startsWith(x, prefix) | Returns true if x starts with prefix |
isNumber(x) | Returns true if x is a number |
Operators
| Operator | Description |
|---|---|
==, != | Equality |
>, <, >=, <= | Comparison |
and, or, not | Logical |
in | Check if value is in array |
+, -, *, / | Arithmetic |